home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Video
/
World of Video.iso
/
gfxprograms
/
3dprograms
/
rayshade-4.0
/
fixes
/
fix024
/
libshade
/
viewing.c.diff
< prev
next >
Wrap
Text File
|
1995-02-13
|
2KB
|
72 lines
*** viewing.c Mon Oct 11 14:59:56 1993
--- viewing.c.frac Mon Oct 11 14:46:03 1993
***************
*** 249,255 ****
Pixel *color; /* resulting color */
int sample; /* sample number */
{
! Float dist;
HitList hitlist;
Color ctmp, fullintens;
extern void focus_blur_ray(), ShadeRay();
--- 249,255 ----
Pixel *color; /* resulting color */
int sample; /* sample number */
{
! Float dist, temp;
HitList hitlist;
Color ctmp, fullintens;
extern void focus_blur_ray(), ShadeRay();
***************
*** 258,263 ****
--- 258,264 ----
* Calculate ray direction.
*/
Stats.EyeRays++;
+ ray->type = EYE_RAY;
ray->dir.x = Screen.firstray.x + x*Screen.scrnx.x + y*Screen.scrny.x;
ray->dir.y = Screen.firstray.y + x*Screen.scrnx.y + y*Screen.scrny.y;
ray->dir.z = Screen.firstray.z + x*Screen.scrnx.z + y*Screen.scrny.z;
***************
*** 280,285 ****
--- 281,293 ----
fullintens.r = fullintens.g = fullintens.b = 1.;
dist = FAR_AWAY;
hitlist.nodes = 0;
+
+ ray->viewpoint = ray->pos;
+ ray->viewdist = 0.;
+ ray->width = 2.*tan(deg2rad(Camera.hfov/2.))/Screen.xres;
+ if ((temp = 2.*tan(deg2rad(Camera.vfov/2.))/Screen.yres) > ray->width) ray->width = temp;
+ ray->stretch = 1.;
+
(void)TraceRay(ray, &hitlist, EPSILON, &dist);
ShadeRay(&hitlist, ray, dist, &Screen.background, &ctmp, &fullintens);
color->r = ctmp.r;
***************
*** 291,293 ****
--- 299,321 ----
color->alpha = 0.;
}
}
+
+ Float PixelSize(ray, dist)
+ Ray *ray;
+ Float dist;
+ {
+ Float s, d;
+
+ d = dist / ray->stretch;
+ if (ray->viewdist < EPSILON) /* eye rays */
+ s = ray->width * d;
+ else if (ray->viewdist < FAR_AWAY) /* infinite light sources !! */
+ s = ray->width / ray->viewdist * (d + ray->viewdist);
+ else
+ s = ray->width;
+ s = fabs(s);
+ if (s < EPSILON) return EPSILON;
+
+ return s;
+ }
+